package com.yeyuanqi.hottop.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.yeyuanqi.hottop.entity.Comment;
import com.yeyuanqi.hottop.mapper.CommentMapper;
import com.yeyuanqi.hottop.service.CommentService;
import com.yeyuanqi.hottop.vo.PageComment;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
* @author yeyuanqi
* @description 针对表【t_comment】的数据库操作Service实现
* @createDate 2022-02-26 20:09:08
*/
@Service
@Transactional
public class CommentServiceImpl extends ServiceImpl<CommentMapper, Comment> implements CommentService {

    @Autowired
    CommentMapper commentMapper;


    /**
     * 通过父评论id=-1查找所有根评论 并按照时间倒序排序
     *
     * @return
     */
    @Override
    public List<PageComment> getParentCommentListByTimeDesc() {
        return commentMapper.getPageCommentListByPageAndParentCommentIdByDesc();
    }

    /**
     * 通过父评论id查找所有子评论
     *
     * @param parentCommentId
     * @return
     */
    @Override
    public List<PageComment> getCommentByParentId(Long parentCommentId) {
        return commentMapper.getPageCommentListByPageAndParentCommentId( parentCommentId);
    }


}
